#include "splashview.h"
#include "item/imageitem.h"
#include <QTimer>
#include "toolkit.h"
#include "resources.h"
#include <QSettings>
#include "sound/GameSounds.h"

splashView::splashView(QWidget *parent) :
    QGraphicsView(parent)
{
    setFrameShape(QFrame::NoFrame);

    m_Scene = new QGraphicsScene(this);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setScene(m_Scene);
    m_Scene->setSceneRect(0.0, 0.0, 640.0, 360.0);
    setGeometry(0.0,0.0,640.0,360.0);

    m_bgItem = new ImageItem(QImage(":/image/splash/splash.jpg"),
                                 QRect(QPoint(0,0),QImage(":/image/splash/splash.jpg").size()));
    m_bgItem->setZValue(0.0);
    m_Scene->addItem(m_bgItem);
    QTimer::singleShot(500,this,SLOT(over()));
}

void splashView::over()
{
    QSettings settings("MySoft", "level");
    ToolKit::m_level = settings.value("Main/level",0).toInt();
    ToolKit::m_rc = new Resources();
    ToolKit::m_bVoice = settings.value("Main/voice",false).toBool();
    ToolKit::m_gamesound = new GameSounds();

    emit splashOver();
}
